# coding=utf-8
from __future__ import unicode_literals

import uuid

from django.db import models

from account.models import User
from utils.date_scraper import now


class Comment(models.Model):
    """ 回复 """
    source = models.CharField(max_length=30)
    object_id = models.BigIntegerField()
    creater = models.ForeignKey(User, related_name="comments")
    content = models.CharField(max_length=288)
    created_time = models.BigIntegerField(default=now)
    # 回复的哪条评论
    comment_to = models.ForeignKey('self', null=True, blank=True)
    # 需要通知的人
    comment_to_user = models.ForeignKey(User, related_name="comment_to_user",
                                        blank=True, null=True)
    # 是否被读过
    is_readed = models.BooleanField(default=False)
    is_deleted = models.BooleanField(default=False)
    uuid = models.SlugField(default=uuid.uuid1, unique=True)

    class Meta:
        db_table = "comment"
        ordering = ["-created_time", ]
